//-----------------------------------------------------------------------------
// Copyright (c) 2011 Blitz Games Studios Ltd
// Initially created on 11/11/2011
//-----------------------------------------------------------------------------

#include "Global.h"
#include "MapStore.h"

//-----------------------------------------------------------------------------
MapStore::MapStore()
{
} 

//-----------------------------------------------------------------------------
MapStore::~MapStore()
{
}

//-----------------------------------------------------------------------------
std::string MapStore::GetFilenameForID(int const i_index) const
{
	return m_mapFileNames[i_index];
}

//-----------------------------------------------------------------------------
void MapStore::Serialise(Json::Value * o_root) const
{
}

//-----------------------------------------------------------------------------
void MapStore::Deserialise(Json::Value const * i_root)
{
	// Get the number of maps and create array to hold filenames to them
	m_noofMaps = i_root->size();
	m_mapFileNames = new std::string[m_noofMaps];

	// Loop through all of the maps and store filename
	Json::Value const * currentItem = NULL;
	for (int itemCount = 0; itemCount < m_noofMaps; ++itemCount)
	{
		currentItem = &((*i_root)[itemCount]);
		int const index = (*currentItem)["id"].asInt();

		m_mapFileNames[index] = (*currentItem)["file"].asString();
	}
}